package com.google.zxing.common;

import java.util.Arrays;

public final class BitMatrix
  implements Cloneable
{
  private final int[] bits;
  private final int height;
  private final int rowSize;
  private final int width;

  public BitMatrix(int paramInt)
  {
    this(paramInt, paramInt);
  }

  public BitMatrix(int paramInt1, int paramInt2)
  {
    if ((paramInt1 < 1) || (paramInt2 < 1))
      throw new IllegalArgumentException("Both dimensions must be greater than 0");
    this.width = paramInt1;
    this.height = paramInt2;
    this.rowSize = ((paramInt1 + 31) / 32);
    this.bits = new int[paramInt2 * this.rowSize];
  }

  private BitMatrix(int paramInt1, int paramInt2, int paramInt3, int[] paramArrayOfInt)
  {
    this.width = paramInt1;
    this.height = paramInt2;
    this.rowSize = paramInt3;
    this.bits = paramArrayOfInt;
  }

  public static BitMatrix parse(String paramString1, String paramString2, String paramString3)
  {
    if (paramString1 == null)
      throw new IllegalArgumentException();
    boolean[] arrayOfBoolean = new boolean[paramString1.length()];
    int i = 0;
    int j = 0;
    int k = -1;
    int m = 0;
    int n = 0;
    while (n < paramString1.length())
    {
      if ((paramString1.charAt(n) == '\n') || (paramString1.charAt(n) == '\r'))
      {
        if (i > j)
        {
          if (k != -1)
            break label98;
          k = i - j;
        }
        label98: 
        while (i - j == k)
        {
          j = i;
          m++;
          n++;
          break;
        }
        throw new IllegalArgumentException("row lengths do not match");
      }
      if (paramString1.substring(n, n + paramString2.length()).equals(paramString2))
      {
        n += paramString2.length();
        arrayOfBoolean[i] = true;
        i++;
      }
      else if (paramString1.substring(n, n + paramString3.length()).equals(paramString3))
      {
        n += paramString3.length();
        arrayOfBoolean[i] = false;
        i++;
      }
      else
      {
        throw new IllegalArgumentException("illegal character encountered: " + paramString1.substring(n));
      }
    }
    if (i > j)
    {
      if (k != -1)
        break label304;
      k = i - j;
    }
    BitMatrix localBitMatrix;
    label304: 
    while (i - j == k)
    {
      m++;
      localBitMatrix = new BitMatrix(k, m);
      for (int i1 = 0; i1 < i; i1++)
        if (arrayOfBoolean[i1] != 0)
          localBitMatrix.set(i1 % k, i1 / k);
    }
    throw new IllegalArgumentException("row lengths do not match");
    return localBitMatrix;
  }

  public void clear()
  {
    int i = this.bits.length;
    for (int j = 0; j < i; j++)
      this.bits[j] = 0;
  }

  public BitMatrix clone()
  {
    return new BitMatrix(this.width, this.height, this.rowSize, (int[])this.bits.clone());
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof BitMatrix));
    BitMatrix localBitMatrix;
    do
    {
      return false;
      localBitMatrix = (BitMatrix)paramObject;
    }
    while ((this.width != localBitMatrix.width) || (this.height != localBitMatrix.height) || (this.rowSize != localBitMatrix.rowSize) || (!Arrays.equals(this.bits, localBitMatrix.bits)));
    return true;
  }

  public void flip(int paramInt1, int paramInt2)
  {
    int i = paramInt2 * this.rowSize + paramInt1 / 32;
    int[] arrayOfInt = this.bits;
    arrayOfInt[i] ^= 1 << (paramInt1 & 0x1F);
  }

  public boolean get(int paramInt1, int paramInt2)
  {
    int i = paramInt2 * this.rowSize + paramInt1 / 32;
    return (0x1 & this.bits[i] >>> (paramInt1 & 0x1F)) != 0;
  }

  public int[] getBottomRightOnBit()
  {
    for (int i = -1 + this.bits.length; (i >= 0) && (this.bits[i] == 0); i--);
    if (i < 0)
      return null;
    int j = i / this.rowSize;
    int k = 32 * (i % this.rowSize);
    int m = this.bits[i];
    for (int n = 31; m >>> n == 0; n--);
    return new int[] { k + n, j };
  }

  public int[] getEnclosingRectangle()
  {
    int i = this.width;
    int j = this.height;
    int k = -1;
    int m = -1;
    for (int n = 0; n < this.height; n++)
      for (int i3 = 0; i3 < this.rowSize; i3++)
      {
        int i4 = this.bits[(i3 + n * this.rowSize)];
        if (i4 != 0)
        {
          if (n < j)
            j = n;
          if (n > m)
            m = n;
          if (i3 * 32 < i)
          {
            for (int i6 = 0; i4 << 31 - i6 == 0; i6++);
            if (i6 + i3 * 32 < i)
              i = i6 + i3 * 32;
          }
          if (31 + i3 * 32 > k)
          {
            for (int i5 = 31; i4 >>> i5 == 0; i5--);
            if (i5 + i3 * 32 > k)
              k = i5 + i3 * 32;
          }
        }
      }
    int i1 = k - i;
    int i2 = m - j;
    if ((i1 < 0) || (i2 < 0))
      return null;
    return new int[] { i, j, i1, i2 };
  }

  public int getHeight()
  {
    return this.height;
  }

  public BitArray getRow(int paramInt, BitArray paramBitArray)
  {
    if ((paramBitArray == null) || (paramBitArray.getSize() < this.width))
      paramBitArray = new BitArray(this.width);
    while (true)
    {
      int i = paramInt * this.rowSize;
      for (int j = 0; j < this.rowSize; j++)
        paramBitArray.setBulk(j * 32, this.bits[(i + j)]);
      paramBitArray.clear();
    }
    return paramBitArray;
  }

  public int getRowSize()
  {
    return this.rowSize;
  }

  public int[] getTopLeftOnBit()
  {
    for (int i = 0; (i < this.bits.length) && (this.bits[i] == 0); i++);
    if (i == this.bits.length)
      return null;
    int j = i / this.rowSize;
    int k = 32 * (i % this.rowSize);
    int m = this.bits[i];
    for (int n = 0; m << 31 - n == 0; n++);
    return new int[] { k + n, j };
  }

  public int getWidth()
  {
    return this.width;
  }

  public int hashCode()
  {
    return 31 * (31 * (31 * (31 * this.width + this.width) + this.height) + this.rowSize) + Arrays.hashCode(this.bits);
  }

  public void rotate180()
  {
    int i = getWidth();
    int j = getHeight();
    BitArray localBitArray1 = new BitArray(i);
    BitArray localBitArray2 = new BitArray(i);
    for (int k = 0; k < (j + 1) / 2; k++)
    {
      localBitArray1 = getRow(k, localBitArray1);
      localBitArray2 = getRow(j - 1 - k, localBitArray2);
      localBitArray1.reverse();
      localBitArray2.reverse();
      setRow(k, localBitArray2);
      setRow(j - 1 - k, localBitArray1);
    }
  }

  public void set(int paramInt1, int paramInt2)
  {
    int i = paramInt2 * this.rowSize + paramInt1 / 32;
    int[] arrayOfInt = this.bits;
    arrayOfInt[i] |= 1 << (paramInt1 & 0x1F);
  }

  public void setRegion(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    if ((paramInt2 < 0) || (paramInt1 < 0))
      throw new IllegalArgumentException("Left and top must be nonnegative");
    if ((paramInt4 < 1) || (paramInt3 < 1))
      throw new IllegalArgumentException("Height and width must be at least 1");
    int i = paramInt1 + paramInt3;
    int j = paramInt2 + paramInt4;
    if ((j > this.height) || (i > this.width))
      throw new IllegalArgumentException("The region must fit inside the matrix");
    for (int k = paramInt2; k < j; k++)
    {
      int m = k * this.rowSize;
      for (int n = paramInt1; n < i; n++)
      {
        int[] arrayOfInt = this.bits;
        int i1 = m + n / 32;
        arrayOfInt[i1] |= 1 << (n & 0x1F);
      }
    }
  }

  public void setRow(int paramInt, BitArray paramBitArray)
  {
    System.arraycopy(paramBitArray.getBitArray(), 0, this.bits, paramInt * this.rowSize, this.rowSize);
  }

  public String toString()
  {
    return toString("X ", "  ");
  }

  public String toString(String paramString1, String paramString2)
  {
    return toString(paramString1, paramString2, "\n");
  }

  @Deprecated
  public String toString(String paramString1, String paramString2, String paramString3)
  {
    StringBuilder localStringBuilder = new StringBuilder(this.height * (1 + this.width));
    for (int i = 0; i < this.height; i++)
    {
      int j = 0;
      if (j < this.width)
      {
        if (get(j, i));
        for (String str = paramString1; ; str = paramString2)
        {
          localStringBuilder.append(str);
          j++;
          break;
        }
      }
      localStringBuilder.append(paramString3);
    }
    return localStringBuilder.toString();
  }

  public void unset(int paramInt1, int paramInt2)
  {
    int i = paramInt2 * this.rowSize + paramInt1 / 32;
    int[] arrayOfInt = this.bits;
    arrayOfInt[i] &= (0xFFFFFFFF ^ 1 << (paramInt1 & 0x1F));
  }

  public void xor(BitMatrix paramBitMatrix)
  {
    if ((this.width != paramBitMatrix.getWidth()) || (this.height != paramBitMatrix.getHeight()) || (this.rowSize != paramBitMatrix.getRowSize()))
      throw new IllegalArgumentException("input matrix dimensions do not match");
    BitArray localBitArray = new BitArray(1 + this.width / 32);
    for (int i = 0; i < this.height; i++)
    {
      int j = i * this.rowSize;
      int[] arrayOfInt1 = paramBitMatrix.getRow(i, localBitArray).getBitArray();
      for (int k = 0; k < this.rowSize; k++)
      {
        int[] arrayOfInt2 = this.bits;
        int m = j + k;
        arrayOfInt2[m] ^= arrayOfInt1[k];
      }
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.google.zxing.common.BitMatrix
 * JD-Core Version:    0.6.2
 */